﻿@model GPS.ENTITYS.ViewModelDKH_GV
@using PagedList.Mvc;
@using GPS.Helpers;
@{
    ViewBag.Title = "Quản lý môn học giảng viên";
}

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/datepicker.js"></script>
<script>
    $(document).ready(function () {
        // load district by province when change in dropdownlist
        $("#ddlDVGTVT_MA").change(function () {
            $.ajax({
                url: '@Url.Action("getKH_MAs", "GPS_DKH_GV")',
                type: 'post',
                data: {
                    ma_DVGT: $('#ddlDVGTVT_MA').val()
                }
            }).done(function (response) {
                // update district by province
                var a = '<option value></option>' + response;   // defaut value
                $("#ddlKH_MA").html(a);

            
            });

            $.ajax({
                url: 'getGV_MAs',
                type: 'post',
                data: {
                    Ma_DVGT: $('#ddlDVGTVT_MA').val(),
                    ma_LOP: null
                }
            }).done(function (response) {
             //   alert(response);
                var a = '<option value></option>' + response;   // defaut value
                $("#ddlGV_MA").html(a);

            });
        });



    });
</script>

<div class="container fdb-div-content fdb-div-corner-all">
    <h3 class="text-center fdb-title-search-form">Quản lý danh sách học viên</h3>
    <div class="row">
        @using (Html.BeginForm("Index", "GPS_DKH_GV", FormMethod.Get))
        {
            <div class="list-group">
                <fieldset class="fs_body">
                    <legend class="head_title">Điều kiện tìm kiếm</legend>
                    <div class="criteria_search">


                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Đơn vị đào tạo:
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.KH_GV_DVGTVT_MA, (SelectList)ViewBag.DVGTVT_MAs, "-- Lựa Chọn --", new { @class = "form-control", @id = "ddlDVGTVT_MA" })
                            </div>
                            <div class="col-md-2 control-label text-left">
                                Mã khóa học
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.KH_GV_KH_MA, (SelectList)ViewBag.DEFAULT_VALUE_DDL, string.Empty, new { @class = "form-control", @id = "ddlKH_MA" })
                                @Html.ValidationMessageFor(model => model.KH_GV_KH_MA)
                            </div>
                        </div>

                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label text-left">
                                Giảng viên
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.KH_GV_GV_MA, (SelectList)ViewBag.DEFAULT_VALUE_DDL, string.Empty, new { @class = "form-control", @id = "ddlGV_MA" })
                                @Html.ValidationMessageFor(model => model.KH_GV_GV_MA)
                            </div>

                        </div>
                    </div>
                    <div class="row margin-top-05 btn_search">
                        <div style="float: right; margin: 0 2px;">
                            @* @Html.NoEncodeActionLink("<span class='glyphicon glyphicon-plus'></span> Thêm mới", "Thêm mới", "Create", "GPS_HocVien", null, htmlAttributes: new { @class = "btn btn-warning btn-sm" })*@
                            @*<button type="submit" class="btn btn-primary btn-sm" name="SearchButton" value="Xuất Excel">
                                    <i class='fa fa-file-excel-o'></i> Xuất Excel
                                </button>
                                @Html.NoEncodeActionLink("<i class='fa fa-file-excel-o'></i> Import Excel", "Import Excel", "ImportExcel", "GPS_HocVien", null, htmlAttributes: new { @class = "btn btn-primary btn-sm" })*@
                        </div>
                        <button type="submit" class="btn btn-warning btn-sm">
                            <span class="glyphicon glyphicon-search"></span> Tìm kiếm
                        </button>
                        @Html.NoEncodeActionLink("<span class='glyphicon glyphicon-plus'></span> Thêm mới", "Thêm mới", "Create", "GPS_DKH_GV", null, htmlAttributes: new { @class = "btn btn-primary btn-sm" })


                    </div>
                </fieldset>
            </div>
        }
        <div class="row">
            <fieldset class="fs_body">
                <legend class="head_title">Kết quả tìm kiếm</legend>
                <div class="row margin-top-05">
                    <div class="divbtnFielset">

                        <div style="float: right;">
                            <label id="lblMessageTotal" style="color:blue; font-weight:bold">Tổng số bản ghi: @ViewBag.TotalRow</label>
                        </div>
                    </div>
                </div>

                <div class="row margin-top-05">
                    <table class="table table-striped table-hover table-bordered table-condensed">
                        <tr>
                            <th>
                                Giảng viên
                            </th>
                            <th>
                                Đơn vị đào tạo
                            </th>
                            <th>
                                Mã khóa học
                            </th>
                            <th>
                                Cấu tạo sửa chữa
                            </th>
                            <th>
                                Đạo đức lái xe
                            </th>
                            <th>
                                Nghiệp vụ vận tải
                            </th>
                            <th>
                                Luật GT Đường bộ
                            </th>
                            <th>
                                Kỹ thuật lái xe
                            </th>
                            <th>
                                Thao tác
                            </th>
                        </tr>
                        @{
                            if (Model.SearchResults != null)
                            {
                                int i = 0;
                                var strDVGT_TEN = string.Empty;
                                var strGV = string.Empty;
                                GPS.DataAccessLayer.DbContextHelper<GPS.DataAccessLayer.GPS_NVContext> _db = GPS.COMMON.Singleton<GPS.DataAccessLayer.DbContextHelper<GPS.DataAccessLayer.GPS_NVContext>>.Inst;
                                foreach (var item in Model.SearchResults)
                                {
                                    <tr>
                                        <td>
                                            @{

                                    var _dgv = _db.GetOne<GPS.DataAccessLayer.DGV>(o => o.GV_MA == item.KH_GV_GV_MA);
                                    strGV = _dgv.GV_HODEM + " " + _dgv.GV_TEN;
                                            }
                                            @Html.Label(strGV)
                                        </td>
                                        <td>
                                            @{

                                    var _dvgtvt = _db.GetOne<GPS.DataAccessLayer.SDONVIGTVT>(o => o.DVGTVT_MA == item.KH_GV_DVGTVT_MA);
                                    strDVGT_TEN = _dvgtvt.DVGTVT_TEN;
                                            }
                                            @Html.Label(strDVGT_TEN)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.KH_GV_KH_MA))
                                        </td>
                                        <td>
                                            @{
                                    if (item.KH_GV_CAUTAOSUACHUA != null && item.KH_GV_CAUTAOSUACHUA == true)
                                    {
                                        @Html.CheckBox("KH_GV_CAUTAOSUACHUA", true, new { @readonly = "readonly" })
                                    }
                                    else
                                    {
                                        @Html.CheckBox("KH_GV_CAUTAOSUACHUA", false, new { @readonly = "readonly" })
                                    }
                                            }
                                        </td>
                                        <td>
                                            @{
                                    if (item.KH_GV_DAODUCLAIXE != null && item.KH_GV_DAODUCLAIXE == true)
                                    {
                                        @Html.CheckBox("KH_GV_DAODUCLAIXE", true, new { @readonly = "readonly" })
                                    }
                                    else
                                    {
                                        @Html.CheckBox("KH_GV_DAODUCLAIXE", false, new { @readonly = "readonly" })
                                    }
                                            }
                                        </td>
                                        <td>
                                            @{
                                    if (item.KH_GV_NGHIEPVUVANTAI != null && item.KH_GV_NGHIEPVUVANTAI == true)
                                    {
                                        @Html.CheckBox("KH_GV_NGHIEPVUVANTAI", true, new { @readonly = "readonly" })
                                    }
                                    else
                                    {
                                        @Html.CheckBox("KH_GV_NGHIEPVUVANTAI", false, new { @readonly = "readonly" })
                                    }
                                            }
                                        </td>
                                        <td>
                                            @{
                                    if (item.KH_GV_LUATGTDB != null && item.KH_GV_LUATGTDB == true)
                                    {
                                        @Html.CheckBox("KH_GV_LUATGTDB", true, new { @readonly = "readonly" })
                                    }
                                    else
                                    {
                                        @Html.CheckBox("KH_GV_LUATGTDB", false, new { @readonly = "readonly" })
                                    }
                                            }
                                        </td>

                                        <td>
                                            @{
                                    if (item.KH_GV_KYTHUATLAIXE != null && item.KH_GV_KYTHUATLAIXE == true)
                                    {
                                        @Html.CheckBox("KH_GV_KYTHUATLAIXE", true, new { @readonly = "readonly" })
                                    }
                                    else
                                    {
                                        @Html.CheckBox("KH_GV_KYTHUATLAIXE", false, new { @readonly = "readonly" })
                                    }
                                            }
                                        </td>
                                        <td align="center">

                                            <a href="@Url.Action("Edit", "GPS_DKH_GV", new { id = item.ID })">
                                                <img src="@Url.Content("~/fonts/grid-edit-icon.png")" title="Sửa" />
                                            </a>

                                            <a href="@Url.Action("Delete", "GPS_DKH_GV", new { id = item.ID })">
                                                <img src="@Url.Content("~/fonts/grid-delete-icon1.gif")" title="Xóa lịch học" onclick="return confirm('Bạn chắc chắn muốn xóa không?');" />
                                            </a>
                                        </td>
                                    </tr>
                                }
                            }
                        }

                    </table>
                </div>

                <div class="row margin-top-05">
                    <div class="pagination-sm">
                        @Html.PagedListPager(Model.SearchResults, page => Url.Action("Index", new
   {
       page,
       Model.KH_GV_DVGTVT_MA,
       Model.KH_GV_KH_MA,
       Model.KH_GV_GV_MA
   }))
                    </div>
                </div>
            </fieldset>
        </div>
    </div>

</div>


<!-- delete modal placeholder-->
<div id='deleteModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='deleteModalContent'></div>
        </div>
    </div>
</div>

<!-- modal placeholder-->
<div id='myModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='myModalContent'></div>
        </div>
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/modalform")
}






